#@head() 
#@header() 
#@aside("ticket")
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
	<!-- Main content -->
	<section class="content">
		<div class="row">
			<!-- right column -->
			<div class="col-md-12">
				<!-- Horizontal Form -->
				<div class="box box-info">
					<div class="box-header with-border">
						<h3 class="box-title">添加工单</h3>
					</div>
					<!-- /.box-header -->
					<!-- form start -->
					<form class="form-horizontal" method="post"
						action="#(path)/ticket/startAdd">
						<input type="hidden" name="ticket.id" value="#(item.id??)" />
						<div class="box-body">
							<div class="form-group">
								<label for="inputEmail3" class="col-sm-2 control-label">客户姓名</label>
								<div class="col-sm-10">
									<select name="ticket.clientid"  id="clientid" class="col-sm-12">
									 #if(item.clientid??!=null)
						        		<option value="#(item.getClient().id)"> #(item.getClient().realname)</option>
						        	#end
									</select>
								</div>
							</div>
							<div class="form-group">
								<label for="inputPassword3" class="col-sm-2 control-label">手机号码</label>
								<div class="col-sm-10">
									<input type="text" id="phone" name="ticket.phone"
										class="form-control" value="#(item.phone??)" />
								</div>
							</div>
							<div class="form-group">
								<label for="inputEmail3" class="col-sm-2 control-label">问题内容</label>
								<div class="col-sm-10">
									<input type="text" id="description" name="ticket.description"
										class="form-control" value="#(item.description??)" />
								</div>
							</div>
							<div class="form-group">
								<label for="inputEmail3" class="col-sm-2 control-label">跟单人</label>
								<div class="col-sm-10">
									<select name="ticket.follower" id="follower" class="user col-sm-12">
									 #if(item.follower??!=null)
						        		<option value="#(item.getClient().id)"> #(item.getFollower().realname)</option>
						        	#end
						        	</select>
								</div>
							</div>
							<div class="form-group">
								<label for="inputEmail3" class="col-sm-2 control-label">完结人</label>
								<div class="col-sm-10">
									<select name="ticket.finisher" id="finisher" class="user col-sm-12">
									 #if(item.finisher??!=null)
						        		<option value="#(item.getFinisher().id)"> #(item.getFinisher().realname)</option>
						        	#end
						        	</select>
								</div>
							</div>
						</div>
						<!-- /.box-body -->
						<div class="box-footer">
							<button type="submit" class="btn btn-info center-block">写好了</button>
						</div>
						<!-- /.box-footer -->
					</form>
				</div>
				<!-- /.box -->
			</div>
			<!--/.col (right) -->
		</div>
		<!-- /.row -->
	</section>
	<!-- /.content -->
</div>
<!-- /.content-wrapper -->
#@footer()
<script>
$(function(){ 
 		$("#clientid").on('change keyup',function(){
 			ajax("#(path)/client/findById",{"id":$("#clientid").val()},function(data){
 				 
                 $('#phone').empty();
                 $('#phone').val(data.phone);
 			});
 		});  
  		
       $("#clientid").select2({
               ajax: {
                   url: "#(path)/client/search",
                   dataType: 'json',
                   delay: 250,
                   data: function(params) {
                       return {
                           key: params.term
                       };
                   },
                   processResults: function(data, params) {
                      
                       return {
                           results: data
                       };
                   },
                   cache: true
               },
               minimumInputLength: 1
        });
      
       $(".user").select2({
              ajax: {
                  url: "#(path)/user/search",
                  dataType: 'json',
                  delay: 250,
                  data: function(params) {
                      return {
                          key: params.term
                      };
                  },
                  processResults: function(data, params) {
                       
                      return {
                          results: data
                      };
                  },
                  cache: true
              },
              minimumInputLength: 1
    });
});
</script>
</body>
</html>